package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicSkDAO;
import com.cssy.yd.logic.entity.LogicSkDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-07-30
 */
public class LogicSkDAOImpl extends SqlMapClientDaoSupport implements LogicSkDAO {

    /**
     * 插入数据
     * @param logicSkDO
     * @return 插入数据的主键
     */
    public String insertLogicSkDO(LogicSkDO logicSkDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicSk.insert", logicSkDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicSkDO
     * @return 查出的记录数
     */
    public Integer countLogicSkDOByExample(LogicSkDO logicSkDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSk.countByDOExample", logicSkDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicSkDO
     * @return 受影响的行数
     */
    public Integer updateLogicSkDO(LogicSkDO logicSkDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicSk.update", logicSkDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicSkDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicSkDO> findListByExample(LogicSkDO logicSkDO) throws DataAccessException {
        List<LogicSkDO> list = getSqlMapClientTemplate().queryForList("LogicSk.findListByDO", logicSkDO);
        return list;
    }

    /**
     * 根据主键获取logicSkDO
     * @param id
     * @return logicSkDO
     */
    public LogicSkDO findLogicSkDOByPrimaryKey(String id) throws DataAccessException {
        LogicSkDO logicSkDO = (LogicSkDO) getSqlMapClientTemplate().queryForObject("LogicSk.findByPrimaryKey", id);
        return logicSkDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    @Override
    public Integer deleteLogicSkDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicSk.deleteByPrimaryKey", id);
        return rows;
    }

    @SuppressWarnings("unchecked")
	@Override
   	public List<LogicSkDO> find(SearchConditions scs)
   			throws DataAccessException {
		List<LogicSkDO> list = getSqlMapClientTemplate().queryForList("LogicSk_ex.find", scs);
   		   return list;
   	}

   	@Override
   	public Integer count(SearchConditions scs) throws DataAccessException {		
   		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSk_ex.count", scs);
   	      return count;
   	}

	@Override
	public Double findLastedDOByOricode(SearchConditions scs)
			throws DataAccessException {
		Double yshk = (Double) getSqlMapClientTemplate().queryForObject("LogicSk_ex.findLastedDOByOricode", scs);
		return yshk;
	}
}